<script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>

    //一级 城市请求 
    let p1 = new Promise((resolve, reject) => {
        $.ajax({
            type: "get",
            url: "./data/1.json",
            data: {},
            success(res) {
                resolve([null, res])
            },
            error(err) {
                resolve([err, undefined])
            }
        })
    })



    // 拿取一级城市结果
    async function getcity() {

        let [err, res] = await p1;

        if (err) {
            alert("出错了")
            return
        }

        let id = res[0].id
        // console.log(id);



        // 二级城市
        let p2 = new Promise((resolve, reject) => {
            $.ajax({
                type: "get",
                url: "./data/2.json",
                data: {
                    id
                },
                success(res) {
                    resolve([null, res])
                },
                error(err) {
                    resolve([err, undefined])
                }
            })
        })


        let [err1, res1] = await p2;
        console.log(err1, res1);

    }
    getcity()








</script>